package cn.xuyun.cc.tcp.vo;

import java.util.HashMap;

import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin;

public class Constants {

	public static final long magic=0x504B474D47520000L; // PKGMGR
	
	
	
	public static HashMap<String, Integer> cmdCode=new HashMap<String, Integer>();
	
	/**

1、发送命令：cmd_set_para vol=40
50 4B 47 4D 47 52 00 00 00 00 00 01 00 00 00 1A         PKGMGR..........
50 72 C4 2C                                             Pr.,  
00 00 00 00 00 00 00 00 00 00 07 D5 00 00 00 06         ................
76 6F 6C 3D 34 30 00 00 00 00                           vol=40.... 
回复：
50 4B 47 4D 47 52 00 00 00 00 00 01 00 00 00 16         PKGMGR..........
50 72 C4 2C     
00 00 00 00 00 00 00 01 00 00 07 D5 00 00 00 02         ................
4F 4B 00 00 E0 39                                       OK...9
2、发送cmd_op_power_on
50 4B 47 4D 47 52 00 00 00 00 00 01 00 00 00 14         PKGMGR..........
50 72 C4 D6                                             Pr..
00 00 00 00 00 00 00 00 00 00 07 D0 00 00 00 00         ................
00 00 00 00       
回复
50 4B 47 4D 47 52 00 00 00 00 00 01 00 00 00 16         PKGMGR..........
50 72 C4 D6                                             Pr..
00 00 00 00 00 00 00 01 00 00 07 D0 00 00 00 02         ................
4F 4B 00 00 78 3B    
	 * 
	 * 504B474D47520000000000010000001A
	 * 50864EAA
	 * 0000000000000000000007D500000006
	 * 766F6C3D34300
	 * 00000000000000000000000000000000
	 */
	static{
		/**
		 * 
		 * 
CMD_OP_POWER_ON	2000
CMD_OP_POWER_OFF	2001
CMD_OP_POWER_REBOOT	2002
CMD_OP_PLAY	2003
CMD_OP_STOP	2004
CMD_GET_RUN_STATE	3002
CMD_GET_DOWN_STATE	3003
CMD_GET_PLAY_STATE	3004
CMD_GET_RUN_ENV	3006
CMD_GET_DEVICE_INFO	3008
CMD_SET_PARA	2005
CMD_GET_PARA	2006
CMD_GET_SCREEN_PIC	4005
CMD_GET_FILE_LIST	4007
CMD_GET_LOG	4008
CMD_SET_TIME	2007
CMD_OP_DEL	3001
CMD_OP_UPGRADE	3000



		 */
	cmdCode.put("CMD_OP_POWER_ON", 2000);
	cmdCode.put("CMD_OP_POWER_OFF", 2001);
	cmdCode.put("CMD_OP_POWER_REBOOT", 2002);
	cmdCode.put("CMD_OP_PLAY", 2003);
	cmdCode.put("CMD_OP_STOP", 2004);
	cmdCode.put("CMD_SET_PARA", 2005);
	cmdCode.put("CMD_GET_PARA", 2006);
	cmdCode.put("CMD_SET_TIME", 2007);
	
	cmdCode.put("CMD_OP_UPGRADE", 3000);
	cmdCode.put("CMD_OP_DEL", 3001);
	cmdCode.put("CMD_GET_RUN_STATE", 3002);
	cmdCode.put("CMD_GET_DOWN_STATE", 3003);
	cmdCode.put("CMD_GET_PLAY_STATE", 3004);
	cmdCode.put("CMD_GET_SCREEN_PIC", 4005);
	cmdCode.put("CMD_GET_RUN_ENV", 3006);
	cmdCode.put("CMD_GET_FILE_LIST", 4007);
	cmdCode.put("CMD_GET_LOG", 4008);
	cmdCode.put("CMD_GET_DEVICE_INFO", 3008);
	
	
	}
	
	public static void main(String[] args) throws Exception{
//		ChannelBuffer totalBuffer=ChannelBuffers.dynamicBuffer();
//		
//		totalBuffer.writeLong(cmdList.get(0).getMagic());//魔术字
//		totalBuffer.writeInt(cmdList.get(0).getVersion());
//		totalBuffer.writeInt(cmdList.get(0).getData_len());
//		totalBuffer.writeInt(cmdList.get(0).getSend_time());
//		totalBuffer.writeInt(cmdList.get(0).getSerial());
//		totalBuffer.writeInt(cmdList.get(0).getType());
//		totalBuffer.writeInt(cmdList.get(0).getCmd());
//		totalBuffer.writeInt(cmdList.get(0).getContent_len());
//		totalBuffer.writeBytes(cmdList.get(0).getContent());
//		System.out.println(totalBuffer.readableBytes());
//		byte[] b=new byte[totalBuffer.readableBytes()];
//		totalBuffer.readBytes(b);
//		FileOutputStream fos=new FileOutputStream("test.bin");
//		fos.write(b);
//		fos.close();
//		System.out.println(HexBin.encode(b));
		
		System.out.println(new String(HexBin.decode("4F4B00000000" +
				"504B474D47520000" +
				"00000001" +
				"00000027" +
				"50874A87" +
				"00000000" +
				"00000000" +
				"000007D7" +
				"00000013" +
				"323031322D31302D32342030313A35353A3139"),"UTF-8"));
		
		System.out.println(new String(HexBin.decode("323031322D31302D32342030313A35353A3139")));
		
	}

	
}
